package org.bigzero.bao

class UserController {
	def scaffold = true
	def adminPortal = {}
	def operatorPortal = {}
	def bossPortal = {}

	def login = {
		if (!params.name) return

		def user = User.findByNameAndPassword(params.name, params.password)
		if (!user){
			flash.message = "${message(code: 'user.login.failed')}"
			return
		}

		session.user = user
		redirect(action: "${user.role.toLowerCase()}Portal")
	}
}
